<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../babel.min.js"></script>
    <script src="../react.development.js"></script>
    <script src="../react-dom.development.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="root"></div>
    <script type="text/babel">
        function FancyBorder(props) {
            return (
                <div className={'FancyBorder FancyBorder-' + props.color}>
                    {props.children}
                </div>
            );
        }

        class LazyLoadBox extends React.Component {
            constructor(props) {

                super(props)
                this.state = { children: <div>hello˜∫</div> }
            }

            handleOnClick = () => {
                setTimeout(() => {
                    const childs = <h1>newly loaded text component</h1>
                    this.setState({ children: childs })
                }, 1200);

            }

            render() {
                return <div>
                    {this.state.children}
                    <button onClick={this.handleOnClick()}>click me to load components</button>
                </div>
            }
        }

        ReactDOM.render(<LazyLoadBox/>,document.getElementById("root"))

    </script>

</body>

</html>